﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveCloud : MonoBehaviour
{
    public GameObject MaxCloud, MinCloud,TopCloud;
    public bool IsMove;
    public int Speed,Speed1,Speed2;
    void Start()
    {
        Speed = 1;
        Speed1 = 1;
        Speed2 = 2;
    }

   
    void Update()
    {
        Cloud(MinCloud);
        Cloud(MaxCloud);
        Cloud(TopCloud);
    }
    /// <summary>
    /// 云移动
    /// </summary>
    /// <param name="obj"></param>
    public void Cloud(GameObject obj)
    {
        if (obj.gameObject.name.Equals("MinCloud"))
        {
            obj.transform.Translate(-Speed, 0, 0);
            if (obj.transform.localPosition.x > 430)
            {
                Speed *= -1;
            }
            if (obj.transform.localPosition.x < -430)
            {
                Speed *= -1;
            }
        }
        else if (obj.gameObject.name.Equals("TopCloud"))
        {
            obj.transform.Translate(-Speed2, 0, 0);
            if (obj.transform.localPosition.x > 530)
            {
                Speed2 *= -1;
            }
            if (obj.transform.localPosition.x < -530)
            {
                Speed2 *= -1;
            }
        }
        else
        {
            obj.transform.Translate(Speed1, 0, 0);
            if (obj.transform.localPosition.x > 430)
            {
                Speed1 *= -1;
            }
            if (obj.transform.localPosition.x < -430)
            {
                Speed1 *= -1;
            }
        }
       
    }
}
